package me.jiatao.mvpdagger2.mvc.userinfo;

import android.os.Handler;

import javax.inject.Inject;

import me.jiatao.mvpdagger2.entity.UserInfo;
import me.jiatao.mvpdagger2.mvc.base.BasePresenter;


/**
 * Created by JiaTao on 2018/8/30.
 * Email: 535318720@qq.com
 * Version: 1.0
 * Description:
 */
public class UserInfoPresenter extends BasePresenter<IUserInfoContract.IUserInfoView, UserInfoModel>
        implements IUserInfoContract.IUserInfoPresenter {

    @Inject
    public UserInfoPresenter(IUserInfoContract.IUserInfoView mView, UserInfoModel mModel) {
        super(mView, mModel);
    }

    @Override
    public void getUsers() {
        getView().onLoading();

        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                UserInfo userInfo = getModel().getUsers();
                if (userInfo == null) {
                    getView().onError();
                } else {
                    getView().onSucceed(userInfo);
                }
            }
        }, 2000);

    }
}
